#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename	:  03-history-lv4.sh
# Version	:  1.0
# Date		:  2020/04/23
# Author	:  Lz
# Email		:  lz843723683@163.com
# History	:     
#             Version 1.0, 2020/04/22
# Function	:   packages - 01.测试安全四级-内存监控程序集成
# Out		:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
MonitorClean_FTLV4(){
	return $TPASS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
MonitorExit_FTLV4(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 用户界面
#
MonitorUSAGE_FTLV4(){
	USAGE_FTLIB "安全四级测试 - 内存监控程序集成"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
MonitorInit_FTLV4(){
        # 调用初始化函数
	Init_FTLIB "MonitorClean_FTLV4"
        # 调用用户界面函数
 	MonitorUSAGE_FTLV4
}


## TODO ：默认安装 kylin-memory-monitor
#
MonitorTest01_FTLV4(){
        # 1. 默认安装 kylin-memory-monitor
        local pkgname="kylin-memory-monitor"
        PkgExist_FTLIB "isExist" "no" "yes" "${pkgname}"
        RetParse_FTLIB "集成${pkgname}包" "False"

        # 2. 默认自启动,内存监控程序
        local svcname="${pkgname}"
        SvcActive_FTLIB "isActive" "no" "${svcname}"
        RetParse_FTLIB "已启动 ${svcname} 服务" "False"

        SvcEnable_FTLIB "isEnable" "no" "${svcname}"
        RetParse_FTLIB "开机自启动 ${svcname} 服务" "False"
}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
MonitorMain_FTLV4(){
	MonitorInit_FTLV4

	MonitorTest01_FTLV4

	return ${TPASS}	
}

MonitorMain_FTLV4
MonitorExit_FTLV4 $?
